#include "customprogressbar.h"

//CustomProgressBar* CustomProgressBar::m_customProgress = nullptr;

CustomProgressBar::CustomProgressBar()
{
    CustomProgressBar(0, 100, 0);
}

CustomProgressBar::CustomProgressBar(int min, int max, int cur)
{
    setRange(min, max);
    setValue(cur);

    // 样式设置
    setMaximumHeight(2);
    setFixedHeight(2);
    setTextVisible(false);
    hide();
}

//CustomProgressBar *CustomProgressBar::instance()
//{
//    return instance(0, 100, 0);
//}

//CustomProgressBar *CustomProgressBar::instance(int min, int max, int cur)
//{
//    if(m_customProgress == nullptr){
//        m_customProgress = new CustomProgressBar(min, max, cur);
//    }
//    return m_customProgress;
//}

//CustomProgressBar *CustomProgressBar::newInstance()
//{
//    return new CustomProgressBar();
//}

//CustomProgressBar *CustomProgressBar::newInstance(int min, int max, int cur)
//{
//    return new CustomProgressBar(min, max, cur);
//}

void CustomProgressBar::handleStartProgress()
{
    show();
}

void CustomProgressBar::handleLoadProgress(int val)
{
    qDebug()<<"load progress = "<<val;
    setValue(val);
}

void CustomProgressBar::handleEndProgress(bool success)
{
    if(success){
        hide();
    }else{
        qDebug()<<"end progress error";
        hide();
    }
}
